<?php

namespace Common\Controller;
use Common\Controller\CommonController;

class PcHomeBaseController extends CommonController
{
    protected function _initialize() {
        parent::_initialize();
    }

    /**
     * 检查用户登录
     */
    protected function check_login() {
        $session_user = session('user');
        if (empty($session_user)) {
            $this->error('您还没有登录！',__ROOT__."/");
        }
    }

    /**
     * 检查用户状态
     */
    protected function check_user() {
        $user_status = M('User')->where(array("user_id" => x_get_user_id()))->getField("status");
        if ($user_status == 2) {
            $this->error('您还没有激活账号，请激活后再使用！', U("user/login/active"));
        }

        if ($user_status==0) {
            $this->error('此账号已经被禁止使用，请联系管理员！', __ROOT__."/");
        }
    }

    public function config_tmpl_path() {
        $tmpl_path = C("X_TMPL_PATH");  //前台模板路径
        $theme     = C('X_DEFAULT_THEME'); //前台模板名称
        define('TMPL_PATH', $tmpl_path . $theme . '/');
        C("TMPL_PARSE_STRING.__HOME_IMG__",  __ROOT__. '/' . TMPL_PATH . 'Public/img');
        C("TMPL_PARSE_STRING.__HOME_CSS__",  __ROOT__. '/' . TMPL_PATH . 'Public/css');
        C("TMPL_PARSE_STRING.__HOME_JS__",   __ROOT__. '/' . TMPL_PATH . 'Public/js');
        C("TMPL_ACTION_SUCCESS", '../Public/' . C("X_TMPL_ACTION_SUCCESS"));
        C("TMPL_ACTION_ERROR", '../Public/' . C("X_TMPL_ACTION_ERROR"));
    }
}